package paper.domain;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import keter.domain.base.BaseUser;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;

/**
 * <p>
 * Class : paper.domain.User
 * <p>
 * Descdription: 学生用户
 * 
 * @author 顾力行-gulx@neusoft.com
 * @version 1.0.0
 */
@Entity
@Table(name = "users")
// 学生表
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class User extends BaseUser {

    public User() {
    }

    public User(Long id) {
        this.id = id;
    }

    // 导师：每个学生只有一个导师
    private User teacher;

    public void setTeacher(User teacher) {
        this.teacher = teacher;
    }

    @ManyToOne
    @JoinColumn(name = "teacher_id")
    public User getTeacher() {
        return teacher;
    }

    private String graduate;// 毕业年份

    @Column(length = 10)
    public String getGraduate() {
        return graduate;
    }

    public void setGraduate(String graduate) {
        this.graduate = graduate;
    }

    // 学位
    private String degree = Degree.BACHELOR.toString();

    public String getDegree() {
        return degree;
    }

    public void setDegree(String degree) {
        this.degree = degree;
    }

    public static enum Degree {
        BACHELOR, // 本科
        MASTER, // 硕士
        PHD // 博士
    }

    // 课题：一对多关系
    private List<Topic> topicList = Lists.newArrayList();

    @JsonIgnore
    @OneToMany(mappedBy = "master")
    public List<Topic> getTopicList() {
        return topicList;
    }

    public void setTopicList(List<Topic> topicList) {
        this.topicList = topicList;
    }
    
    private String QQ;//学号
    public String getQQ() {
        return QQ;
    }
    public void setQQ(String QQ) {
        this.QQ = QQ;
    }
    
    private String sno;//学号
    public String getSno() {
    	return sno;
    }
    public void setSno(String sno) {
    	this.sno = sno;
    }

    // TODO: 论文：一对一
}